<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<? include '../console/mysql.php'; session_start();$mysql=new Mysql()?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../js/jquery-1.8.3.min.js"></script>
<title>无标题文档</title>
<link href="../css/style_css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#edit_div{
	background-color:rgba(51,51,51,0.6);
	width:100%; height:100%;
	padding-top:100px;
	z-index:10;
	position:fixed;
	top:0px; left:0px;
	display:none;
}
</style>
</head>

<?
if(isset($_POST['edit_submit'])){
	$item_id=$_POST['item_id'];
	$tag=$_POST['tag'];
	$un=$_POST['un'];
	$pw=$_POST['pw'];
	
	$status=$mysql->editItem($item_id,$tag,$un,$pw);
	if($status==0) alert("更改失败");
}
?>

<body><center>
<table border="0" cellpadding="10" cellspacing="0" class="table01">
<tr align="left"><th width="25%">标签</th><th width="25%">用户名</th><th width="25%">密码</th><th width="25%">编辑</th></tr>
<?
$username=$_GET['username'];
$result_array=$mysql->getPasswd($username);
foreach($result_array as $v){
	echo "<tr><td>".$v['tag']."</td><td>".$v['un']."</td><td>".$v['pw']."</td><td><input type='button' value='' class='button03' onclick='edit_item(".$v['id'].")'></td></tr>";
}
?>
</table>

<div id="edit_div" align="center">
<table width="300" border="0" cellpadding="5" cellspacing="0" class="table02">
<form action="" method="post">
<tr><td width="120"><label>标签:</label></td><td><input type="text" name="tag" class="text04" /></td></tr>
<tr><td><label>用户名:</label></td><td><input type="text" name="un" class="text04" /></td></tr>
<tr><td><label>密码:</label></td><td><input type="text" name="pw" class="text04" /></td></tr>
<input type="hidden" name="item_id" id="item_id" />
<tr align="center"><td colspan="2"><input type="submit" value="确认" name="edit_submit" class="button04"/></tr>
</table>
</div>
</center></body>
<script language="javascript">
$(".table01 tr:even").css("background-color","#0C6").css("color","#FFF");;
$(".table01 tr:odd").css("background-color","#FFF").css("color","#0C6");
$(".table01 td").css("padding-left","80px");
$(".table01 th").css("padding-left","80px");

function edit_item(id){
	$("#item_id").val(id);
	$("#edit_div").css("display","block");
}
</script>
</html>